Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Aug 26, 2025

For WOOMOB-1170

Description

This PR implements POS catalog sync endpoints with full catalog generation capabilities. The catalog download URL is provided in the job API response when it is complete.

Key Changes:

Catalog Generation Endpoints:

  • generateCatalog(for:forceGenerate:) - Initiates asynchronous catalog generation and returns a job ID
    • POST /wp-json/wc/v3/catalog with fields=["id", "name", "type", "sku", "global_unique_id", "price", "regular_price", "sale_price", "on_sale", "downloadable", "parent_id", "images", "attributes", "manage_stock", "stock_quantity", "stock_status"] with CatalogGenerationResponse
  • checkCatalogStatus(for:jobID:) - Checks catalog generation job status and provides download URL when complete
    • GET /wp-json/wc/v3/catalog/status/$job_id with CatalogStatusResponse

Response Models:

  • CatalogGenerationResponse - Contains job ID job_id: string for tracking catalog generation
  • CatalogStatusResponse - Parses status: string, progress: float, and download_url: string? (available when the job is complete) for catalog jobs
  • CatalogStatus enum - Defines pending, processing, and complete states

Catalog generation works asynchronously - merchants initiate generation with generateCatalog, then poll status with checkCatalogStatus until completion. The download URL is provided in the status response when the job completes.

Downloading the catalog file (JSON for now) with the download URL will be in a separate PR, as it involves using a background session.

Testing:

Comprehensive test coverage includes:

  • Parameter validation for all endpoints
  • Response parsing for different catalog states (pending, processing, complete)
  • Error handling and networking failure scenarios
  • Edge cases for pagination and date handling

The endpoints are currently marked with periphery:ignore comments until integration with the broader catalog sync system is complete.

Steps to reproduce

Just CI passing is sufficient, as the remote isn't used in the app yet.

Testing information

I tested with

let catalogResponse = try await syncRemote.generateCatalog(for: siteID)
print("Job ID: \(catalogResponse.jobID)")
let jobID = catalogResponse.jobID
var isNotComplete = true
while isNotComplete {
    let statusResponse = try await syncRemote.checkCatalogStatus(for: siteID, jobID: jobID)
    if statusResponse.status == .complete {
        isNotComplete = false
        print("Job complete, download URL: \(statusResponse.downloadURL)")
    } else {
        print("Job status: \(statusResponse.status), progress \(statusResponse.progress), waiting 2 seconds...")
        try await Task.sleep(nanoseconds: 2_000_000_000)
    }
}

in the app to verify that the remote methods are working as expected.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added this to the 23.2 milestone Aug 26, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 26, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16041-95865d6
Version23.1
Bundle IDcom.automattic.alpha.woocommerce
Commit95865d6
Installation URL3dgerbrjkea58
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jaclync jaclync requested a review from joshheald August 26, 2025 05:56
@jaclync jaclync changed the title Add POS catalog sync endpoints for incremental sync and catalog generation [Local Catalog] Add POS catalog sync endpoints for incremental sync and catalog generation Aug 26, 2025
@jaclync jaclync changed the title [Local Catalog] Add POS catalog sync endpoints for incremental sync and catalog generation [Local Catalog] Add POS catalog generation/status endpoints for full sync Aug 26, 2025
@jaclync jaclync changed the title [Local Catalog] Add POS catalog generation/status endpoints for full sync [Local Catalog] Implement POS catalog generation/status endpoints for full sync Aug 26, 2025
Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well – great work getting this far so fast 💜

@jaclync jaclync merged commit 12e2fcf into trunk Aug 27, 2025
16 checks passed
@jaclync jaclync deleted the feat/WOOMOB-1170-full-sync-remote branch August 27, 2025 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants